package com.txby.wrApi.config;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.txby.wrApi.component.interceptor.CrossFilter;
import com.txby.wrApi.component.interceptor.IndexListener;
import com.txby.wrApi.component.interceptor.XssAndSqlFilter;
@Configuration
public class ServerConfig {
	@Bean
	public FilterRegistrationBean indexFilterRegistration() {
		//添加跨域过滤器
		FilterRegistrationBean registration = new FilterRegistrationBean(new CrossFilter());
//		registration.addUrlPatterns("/");
		return registration;
	}
	@Bean
	public FilterRegistrationBean indexFilterRegistration2() {
		//添加安全过滤器
		FilterRegistrationBean registration = new FilterRegistrationBean(new XssAndSqlFilter());
//		registration.addUrlPatterns("/");
		return registration;
	}

	@Bean
	public ServletListenerRegistrationBean servletListenerRegistrationBean() {
		ServletListenerRegistrationBean servletListenerRegistrationBean = new ServletListenerRegistrationBean();
		servletListenerRegistrationBean.setListener(new IndexListener());
		return servletListenerRegistrationBean;
	}

}
